package com.zzyk.main.mapper;

import com.zzyk.main.model.pojo.DeviceOriginData;
import com.zzyk.main.model.pojo.MedicalReportMonth;
import com.zzyk.main.model.vo.DateAndString;
import com.zzyk.main.model.vo.DeviceOriginDataVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface DeviceOriginDataMapper {
    /**
     * delete by primary key
     *
     * @param id primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * insert record to table
     *
     * @param record the record
     * @return insert count
     */
    int insert(DeviceOriginData record);

    /**
     * insert record to table selective
     *
     * @param record the record
     * @return insert count
     */
    int insertSelective(DeviceOriginData record);

    /**
     * select by primary key
     *
     * @param id primary key
     * @return object by primary key
     */
    DeviceOriginData selectByPrimaryKey(Integer id);

    /**
     * update record selective
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKeySelective(DeviceOriginData record);

    /**
     * update record
     *
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(DeviceOriginData record);

    /**
     * 根据设备ID去查询设备最新原始数据
     *
     * @param id
     * @return
     */
    DeviceOriginData selectByDeviceId(@Param("id") Integer id);

    /**
     * 根据条件获取设备原始数据
     *
     * @param eId   企业 ID
     * @param dId   设备 ID
     * @param param 需要查询哪个字段
     * @param bDate
     * @param eDate
     * @return
     */
    List<DateAndString> selectByEIDAndDIDAndParam(@Param("eId") Integer eId, @Param("dId") Integer dId, @Param("param") String param, @Param("bDate") Date bDate, @Param("eDate") Date eDate);

    /**
     * 获取企业下所有设备的原始数据
     *
     * @param enterprise
     * @param deviceList
     * @return
     */
    List<DeviceOriginData> selectByEnterprise(@Param("enterprise") Integer enterprise, @Param("deviceList") Integer[] deviceList);

    /**
     * 根据条件获取设备原始数据
     *
     * @param eId   企业 ID
     * @param dId   设备 ID
     * @param param 需要查询哪个字段
     * @param bDate
     * @param eDate
     * @return
     */
    List<DeviceOriginDataVO> selectByEIDAndDIDAndParamTest(@Param("eId") Integer eId, @Param("dId") Integer dId, @Param("param") String param, @Param("bDate") Date bDate, @Param("eDate") Date eDate);

    /**
     * 根据ClientId获取数据时间
     *
     * @param clientId
     * @return
     */
    Date selectDataTimeByClientId(@Param("clientId") String clientId);

    List<DeviceOriginData> selectall();

    MedicalReportMonth selectMedicalReportMonth(@Param("month") String month, @Param("enterprise") Integer enterprise, @Param("deviceList") Integer[] deviceList);
}